package com.aiti.lulian.controller;

import com.aiti.base.core.base.controller.WebController;
import com.aiti.base.core.utils.message.Message;
import com.aiti.lulian.dto.CardTemplateStyleDto;
import com.aiti.lulian.entity.CardTemplateStyle;
import com.aiti.lulian.service.CardTemplateStyleService;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;


@RestController
@RequestMapping("/cardTemplateStyle")
public class CardTemplateStyleController extends WebController {

    @Autowired
    private CardTemplateStyleService cardTemplateStyleService;

    @PostMapping
    public Message save(@RequestBody CardTemplateStyle entity) {
        return cardTemplateStyleService.saveStyle(entity);
    }

    @PutMapping
    public Message update(@RequestBody CardTemplateStyle entity) {
        return cardTemplateStyleService.updateStyle(entity);
    }

    @DeleteMapping("/delete")
    public Message delete(@RequestParam String baseId) {
        return cardTemplateStyleService.deleteStyle(baseId);
    }

    @GetMapping("/detail")
    public Message detail(String baseId, @RequestParam(value = "templateType") String templateType) {

        return Message.success(cardTemplateStyleService.preDetail(baseId, templateType));
    }


    @GetMapping("/page")
    public Message page(CardTemplateStyleDto dto) {
        Page page = this.startPage(dto);
        return cardTemplateStyleService.styleList(page, dto);
    }

    @GetMapping("/prePage")
    public Message prePage(CardTemplateStyleDto dto) {
        Page page = this.startPage(dto);
        return cardTemplateStyleService.preStyleList(page, dto);
    }

//    @PostMapping("/saveBatch")
//    public Message save(@RequestBody CardTemplateStyleDto dto) {
//        List<CardTemplateStyle> styleList = dto.getStyleList();
//        if(!CollectionUtils.isEmpty(styleList)){
//            return cardTemplateStyleService.saveStyleBatch(styleList);
//        }else{
//            return Message.success();
//        }
//
//
//    }
}